<?php 
 /**
  * 类文件加载路径
  * @author Administrator
  */
class PathConfig
{
	public $path=array();
	
	public function __construct()	{
		  $this->path = array (
				'web'        =>WEB_DIR,
				'slash'      => DIRECTORY_SEPARATOR,
		);
	}
	/**
	 * 常用类文件加载路径
	 * @param unknown_type $name 类名
	 * @return string
	 */
	public function classConfig($name)	{
		$lib = 'lib'.$this->path['slash'];
		$class = array(
			'Sql'               => 'Sql.php', 
			'Toos'              => 'Toos.php',                                 //工具类
			'jmail'             => 'jmail.php',                                //发送邮件类
			'Page'              =>'Page.php',                                 //分页类
			'File'	            => 'File.php',                                 //操作文件
			'TableConfig'       => 'TableConfig.php',                          //数据表
			'Cache'	            => 'Cache.php',                                //文件缓存
			'Ueditor'           => 'Ueditor.php',                              //编辑器
			'Upload'            => 'Upload.php',                               //上传图片
			'Common'            => 'Common.php',                               //共用方法类
			'VerificationCode'  => 'Verificationcode.php',                     //验证码
			'Upload'            => 'Upload.php',                                //上传文件 
			'Calendar'          => 'Calendar.php',                              //日历
			'BaseController'    => $this->path['web'].$this->path['slash'].'DSC'.$this->path['slash'].'controller'.$this->path['slash'].'BaseController.php' ,   //基本类
			'ClassManager'      => 'ClassManager.php',                             //获得类
			'HttpDaoManager'    => $this->path['web'].$this->path['slash'].'DSC'.$this->path['slash'].'dao'.$this->path['slash'].'HttpDaoManager.php' ,          //获得dao类
			'HttpServerManager' => $this->path['web'].$this->path['slash'].'DSC'.$this->path['slash'].'server'.$this->path['slash'].'HttpServerManager.php' ,          //获得dao类
			'Email'             =>  'Email.php',    
			'Zend_Mail'         => 'Zend'.$this->path['slash'].'Mail.php',    
			'Zend_Mail_Transport_Smtp' =>'Zend'.$this->path['slash'].'Mail'.$this->path['slash'].'Transport'.$this->path['slash'].'Smtp.php',
			//支付宝
			'Alipay'           => 'alipay'.$this->path['slash'].'Alipay.php',
			'AlipaySubmit'     => 'alipay'.$this->path['slash'].'alipay_submit.class.php',
			'Tenpay'           => 'tenpay'.$this->path['slash'].'Tenpay.php',
			'QC'           => 'QQ'.$this->path['slash'].'QC.class.php'
				
		);
		if (empty($class[$name]))
		{
			return '';
		}		
		return $class[$name];
	}
	/**
	 * 组成类文件路径
	 * @param unknown_type $classname 类名
	 * @return string
	 */
	public function classpath($classname,$work_dir)	{
		$path=$this->classConfig($classname);
		if (!empty($path))		{
			return  $path;
		}
		else{
			$model  = explode('Controller',$classname);
			$server =   explode('Server',$classname);
			$dao =   explode('Dao',$classname);
			
			$controllerName = $this->path['web'].$this->path['slash'].'DSC'.$this->path['slash'].'controller'.$this->path['slash'].$work_dir.$this->path['slash'].$model[0].'Controller.php';
			$serverName = $this->path['web'].$this->path['slash'].'DSC'.$this->path['slash'].'server'.$this->path['slash'].$server[0].'Server.php';
			$daoName = $this->path['web'].$this->path['slash'].'DSC'.$this->path['slash'].'dao'.$this->path['slash'].$dao[0].'Dao.php';
			
			if (count($model)==2&&file_exists($controllerName))	{
					return $controllerName;
			}
			else if (count($server)==2&&file_exists($serverName)) {
					return $serverName;
			}
			else if (count($dao)==2&&file_exists($daoName)){
					return $daoName;
			}
			else{
				return  $classname;
			}
		}
	}
}
?>